package com.hubei.controller;

import com.hubei.pojo.User;
import com.hubei.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

@Controller
public class UserController {
    @Autowired
    private UserService userService;
    @RequestMapping("/user_list.action")
    public String queryUserList(Model model) {

        List<User> list = userService.queryUserList();
        model.addAttribute("userList", list);




//        List<User> list = new ArrayList<>();
//        list.add(new User(1,"王伟","男"));
//        list.add(new User(2,"张力","男"));
//        list.add(new User(3,"王五","男"));
//        model.addAttribute("userList",list);
        return "user_list";
    }
    @RequestMapping("/user_add.action")
    public String userAdd() {

        return "user_add";
    }
}
